<template>
	<view>
		<home v-if="tabPage=='home'" @indexTab="indexTab"></home>
		<find v-if="tabPage=='find'"></find>
		<service v-if="tabPage=='service'"></service>
		<college v-if="tabPage == 'college'"></college>
		<my v-if="tabPage == 'my'"></my>
		<view class="tabBarStyle">
			<view class="weui-flex">
				<block v-for="(item,idx) in tabBarArr" :key="idx">
					<view class="weui-flex__item" @tap.stop="tabbar(item.com)">
						<view class="placeholder" :class="tabPage == 'home'?'actave':''">
							<view v-show="item.com">
								<image
									:src="tabPage ==item.com?'../../static/blueLagoon/'+item.com+'Actave.png': '../../static/blueLagoon/'+item.com+'.png'">
								</image>
								{{item.text}}
							</view>
						</view>
					</view>
				</block>
			</view>
		</view>
		<!-- <view style="height: 300upx;">
		</view>
		<block v-for="(item,idx) in pagelist" :key="idx">
			<view @click="nav(item.url)" style="height: 80upx;">
				{{item.title}}
			</view>
		</block> -->
	</view>
</template>
<script>
	export default {
		data() {
			return {
				pagelist: [{
						title: '我的顾问1',
						url: '/pagesMy/my/counselor/counselor?idx=1'
					},
					{
						title: '我的顾问2',
						url: '/pagesMy/my/counselor/counselor?idx=2'
					},
					{
						title: '健康',
						url: '/pages/subpackage/home/healthData/healthData'
					},
					{
						title: '按科室',
						url: '/pages/subpackage/find/scientifically/scientifically'
					},
					{
						title: '按部位',
						url: '/pages/subpackage/find/Partsofthequery/Partsofthequery'
					},
					{
						title: '食材库',
						url: '/pages/subpackage/find/foodImage/foodImage'
					},
					{
						title: '食材分类',
						url: '/pages/subpackage/find/foodIngredient/foodIngredient'
					},
					{
						title: '更多菜谱',
						url: '/pages/subpackage/find/moreRecipes/moreRecipes'
					},
					{
						title: '分享详情',
						url: '/pages/subpackage/find/share/share'
					},
					{
						title: '发布页面',
						url: '/pages/subpackage/find/postAmessage/postAmessage'
					}, {
						title: '健康报告',
						url: '/pages/subpackage/home/HealthReport/HealthReport'
					}, {
						title: '健康筛查',
						url: '/pages/subpackage/home/major/major'
					},
				],
				tabPage: 'college',
				tabBarArr: [{
					text: '首页',
					com: 'home'
				}, {
					text: '发现',
					com: 'find'
				}, {
					text:'服务',
					com:'service'
				},
				{
					text: '商城',
					com: 'college'
				}, {
					text: '我的',
					com: 'my'
				}],
			}
		},
		onLoad() {
			wx.showShareMenu({
				withShareTicket: true,
				//设置下方的Menus菜单，才能够让发送给朋友与分享到朋友圈两个按钮可以点击
				menus: ["shareAppMessage", "shareTimeline"]
			})
			let _this = this;
			uni.$on('indexTab', function(data) {
				_this.tabPage = data.page
			})
		},
		methods: {
			nav(url) {
				uni.navigateTo({
					url: url
				})
			},
			tabbar(e) {
				console.log(e)
				if (e !== undefined) {
					this.tabPage = e
				}
			},
			//发送给朋友
			onShareAppMessage(res) {
				// 此处的distSource为分享者的部分信息，需要传递给其他人
				let distSource = uni.getStorageSync('distSource');
				console.log('anotherUserId',uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').userId,
				'anotherUserName',uni.getStorageSync('userInfo').nickName,
				'code',uni.getStorageSync('InvitationCode'),
				'avatarUrl',uni.getStorageSync('userInfo').avatarUrl)
				if (distSource == 'InviteYourFamily') {
					return {
						title: '百岁园健康',
						type: 0,
						path: '/pagesMy/my/interconnect/interconnect?anotherUserId='+uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').userId+
						'&anotherUserName='+uni.getStorageSync('userInfo').nickName+
						'&code='+uni.getStorageSync('InvitationCode')+
						'&avatarUrl='+uni.getStorageSync('userInfo').avatarUrl,
						summary: "为了让你更健康，我想邀请你关联家人健康，让我每天为你守护",
						imageUrl: "https://58d.oss-cn-hangzhou.aliyuncs.com/goods/ttg_1596073788000.png"
					}
				}
			},
		}
	}
</script>
<style lang="scss">
</style>
